package com.example.recruitment.service.impl;

import com.example.recruitment.entity.Job;
import com.example.recruitment.mapper.JobMapper;
import com.example.recruitment.service.JobService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
public class JobServiceImpl implements JobService {

    @Autowired
    private JobMapper jobMapper;

    @Override
    public List<Job> findAll() {
        return jobMapper.findAll();
    }

    @Override
    public List<Job> findAll(Job query) {
        return jobMapper.findAll(query);
    }

    @Override
    public Job findById(Long id) {
        return jobMapper.findById(id);
    }

    @Override
    public List<Job> findByDepartment(String department) {
        return jobMapper.findByDepartment(department);
    }

    @Override
    @Transactional
    public boolean add(Job job) {
        return jobMapper.insert(job) > 0;
    }

    @Override
    @Transactional
    public boolean update(Job job) {
        return jobMapper.update(job) > 0;
    }

    @Override
    @Transactional
    public boolean deleteById(Long id) {
        return jobMapper.deleteById(id) > 0;
    }

    @Override
    @Transactional
    public boolean updateStatus(Long id, String status) {
        return jobMapper.updateStatus(id, status) > 0;
    }

    @Override
    public long count() {
        return jobMapper.count();
    }

    @Override
    public List<Job> findLatest(int limit) {
        return jobMapper.findLatest(limit);
    }

    @Override
    public long countByStatus(String status) {
        return jobMapper.countByStatus(status);
    }
} 